<?php
/**
 * This file is part of PHPOOF
 *
 * PHPOOF is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * PHPOOF is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with PHPOOF; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @author $Author$
 * @version $Rev$
 * @updated $Date$
 *
 * @copyright The PHPOOF Team <lucasrsp@gmail.com> http://phpoof.sf.net
 */

namespace php\app\geo\googlemaps;

use php\mvc\App;
use php\mvc\Controller;
use php\mvc\Model;
use php\util\Hashtable;

/**
 * Map Controller
 */
class MapController extends Controller {

	public function defaultAction( Model $model, Hashtable $args ) {
		//default values;
		$model->zoom = '17';
		$model->mapTypeId = 'ROADMAP';
		$model->lat = 0;
		$model->lng = 0;
		$model->contentString = "";
		$model->label = "";
		if ($args->zoom) $model->zoom = intval($args->zoom);
		if ($args->mapTypeId) $model->maptTypeId = $args->mapTypeIde;
		if ($args->lat) $model->lat = (double)$args->lat;
		if ($args->lng) $model->lng = (double)$args->lng;
		if ($args->label) $model->label = $args->label;
		if ($args->contentString) $model->contentString = $args->contentString ;
	}

	public static function createURL( $name, $lat, $lng, $zoom = 10 ) {
		return "/app/geo/googlemaps/map?"                                        
			. "label=" . urlencode($name)
			. "&lat=" . ((double)$lat)
			. "&lng=" . ((double)$lng)
			. "&zoom=" . intval($zoom);
	}

}
